<template>
 <div>
     <el-form :model="user"  ref='ruleForm' label-width="100px">
        <el-form-item label="用户名" prop="username">
            <el-input v-model="user.username" placeholder=""></el-input>
        </el-form-item>
        <el-form-item label="密码" prop="password">
            <el-input v-model="user.password" placeholder=""></el-input>
        </el-form-item>
        <el-form-item >
            <el-button type="primary" @click="reg">登陆</el-button>
        </el-form-item>
     </el-form>


 </div>
</template>

<script>
export default {
 data() {
  return {
    user:{
        username:'',
        password:''
    },

  }
 },
 components: {

 },
 methods: {
     reg(){
         console.log('111')
               this.axios({
                  url:'http://127.0.0.1:8000/login/',
                  method:'post',
                  data:this.user,
              }).then(res=>{
                  if(res.data.code==200){
                      this.$message('登陆成功')
                      
                  }else{
                      this.$message('用户名或密码错误')
                  }
              })
     }
 },


}


</script>
